<?php 
namespace app\admin\controller;
class System extends Comm{
	//首页
	public function lunbo_list(){
		//面包屑标签显示
		$controller = request()->controller();
		$action = request()->action();
		$controller = model('Role')->where(['controller'=>$controller])->find()->rname;
		$action = model('Role')->where(['action'=>$action])->find()->rname;
		$this->assign('controller',$controller);
		$this->assign('action',$action);

		foreach(model('Lunbo')->select() as $val){
			$data[] = $val->toArray();
		}
		$this->assign('data',$data);
		return $this->fetch();
	}

	//添加轮播
	public function lunbo_add(){
		return $this->fetch();
	}

	//处理添加
	public function lunbo_doadd(){
		$file = request()->file('thumb');
		$path = ROOT_PATH.'public'.DS.'static'.DS.'upload'.DS.'system';
		$info = $file->move($path);
		if($info){
			$savename = $info->getSavename();
		}else{
			echo $file->getError();
		}
		$_POST['thumb'] = $savename;
		$res = model('Lunbo')->allowfield(true)->save($_POST);
		if($res > 0){
			$this->success('成功');
		}

	}

	//处理删除
	public function do_del(){
		$res = model('Lunbo')->where(['id'=>$_POST['id']])->delete();
		if($res > 0){
			$this->success('删除成功');
		}
	}



}



 ?>